---
title: "Google Auth Setup "
space: "Google Auth"
url: "https://qejaverse-prod.jh.frappe.cloud/google-auth-setup "
updated: "2026-08-15"
---

## Overview
This document provides step-by-step instructions to configure Google OAuth social login for CasaHub application.

---

## Prerequisites
- Access to CasaHub Frappe site (local or production)
- Administrator credentials
- Google Cloud Console access

---

## OAuth Credentials

### Google Cloud Project Details
- **Project ID:** `casahub-476121`
- **Client ID:** `553782146847-4behr365rs36qhc5rd7p9vs1n854dagq.apps.googleusercontent.com`
- **Client Secret:** `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`
- **Console URL:** [https://console.cloud.google.com/auth/clients?project=casahub-476121](https://console.cloud.google.com/auth/clients?project=casahub-476121)

---

## Setup Instructions

### Step 1: Update Google Cloud Console Settings

1. **Navigate to OAuth Client Settings**
   - Go to: [https://console.cloud.google.com/auth/clients?project=casahub-476121](https://console.cloud.google.com/auth/clients?project=casahub-476121)
   - Click on the OAuth 2.0 Client ID: `553782146847-4behr365rs36qhc5rd7p9vs1n854dagq.apps.googleusercontent.com`

2. **Update Authorized JavaScript Origins**
   
   Add the following origins based on your environment:
   
   **For Production (Frappe Cloud):**
   ```
   https://casahub.jh.frappe.cloud
   ```
   
   **For Local Development:**
   ```
   http://casahub.local
   http://localhost:8000
   ```

3. **Update Authorized Redirect URIs**
   
   Add the following redirect URIs:
   
   **For Production (Frappe Cloud):**
   ```
   https://casahub.jh.frappe.cloud/api/method/frappe.integrations.oauth2_logins.login_via_google
   https://casahub.jh.frappe.cloud/api/method/frappe.integrations.oauth2_logins.custom/google
   ```
   
   **For Local Development:**
   ```
   http://casahub.local/api/method/frappe.integrations.oauth2_logins.login_via_google
   http://casahub.local/api/method/frappe.integrations.oauth2_logins.custom/google
   ```

4. **Save Changes**
   - Click **Save** at the bottom of the page

---

### Step 2: Configure Frappe Site

#### Option A: Via Bench Command (Recommended)

**For Production Site:**
```bash
cd /home/amirah-michelle/frappe-bench

# Set Google OAuth credentials
bench --site casahub.jh.frappe.cloud set-config google_client_id "553782146847-4behr365rs36qhc5rd7p9vs1n854dagq.apps.googleusercontent.com"

bench --site casahub.jh.frappe.cloud set-config google_client_secret "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"

# Restart the site
bench --site casahub.jh.frappe.cloud restart
```

**For Local Development Site:**
```bash
cd /home/amirah-michelle/frappe-bench

# Set Google OAuth credentials
bench --site casahub.local set-config google_client_id "553782146847-4behr365rs36qhc5rd7p9vs1n854dagq.apps.googleusercontent.com"

bench --site casahub.local set-config google_client_secret "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"

# Restart the site
bench restart
```

#### Option B: Manual Configuration

**Edit site_config.json:**
```bash
# For local site
nano sites/casahub.local/site_config.json

# For production site
nano sites/casahub.jh.frappe.cloud/site_config.json
```

**Add the following to the JSON file:**
```json
{
  "google_client_id": "553782146847-4behr365rs36qhc5rd7p9vs1n854dagq.apps.googleusercontent.com",
  "google_client_secret": "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"
}
```

**Restart the site:**
```bash
bench restart
```

---

### Step 3: Create Social Login Key in Frappe

1. **Login as Administrator**
   - Go to your Frappe site
   - Login with administrator credentials

2. **Navigate to Social Login Key**
   - Press `Ctrl+K` (or `Cmd+K` on Mac) to open the search bar
   - Type "Social Login Key" and press Enter
   - Or directly visit: `http://casahub.local/app/social-login-key`

3. **Create New Social Login Key**
   - Click **"New"** button
   - Fill in the following details:

   | Field | Value |
   |-------|-------|
   | **Social Login Provider** | Google |
   | **Client ID** | `553782146847-4behr365rs36qhc5rd7p9vs1n854dagq.apps.googleusercontent.com` |
   | **Client Secret** | `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` |
   | **Enable Social Login** | ✅ Checked |
   | **Redirect URI** | See below based on environment |

   **Redirect URI for Production:**
   ```
   https://casahub.jh.frappe.cloud/api/method/frappe.integrations.oauth2_logins.custom/google
   ```

   **Redirect URI for Local:**
   ```
   http://casahub.local/api/method/frappe.integrations.oauth2_logins.custom/google
   ```

4. **Save the Document**
   - Click **Save**

---

### Step 4: Enable Social Login in System Settings

1. **Navigate to System Settings**
   - Search for "System Settings" in the awesome bar
   - Or visit: `http://casahub.local/app/system-settings`

2. **Enable Social Login**
   - Scroll to **Login Settings** section
   - Check ✅ **Enable Social Login**
   - Click **Save**

---

## Testing

### Test Google OAuth Login

1. **Logout** from your current session
2. Navigate to the login page:
   - Local: `http://casahub.local/micasa/login`
   - Production: `https://casahub.jh.frappe.cloud/micasa/login`
3. Click **"Continue with Google"** button
4. Select your Google account
5. Authorize CasaHub to access your Google profile
6. You should be redirected back and logged in automatically

### Expected Behavior

✅ **Success:**
- User is redirected to Google login
- After authorization, user is redirected back to CasaHub
- User is automatically logged in
- If first-time user, account is created and onboarding flow starts

❌ **Common Issues:**

| Issue | Solution |
|-------|----------|
| "Redirect URI mismatch" error | Verify redirect URIs in Google Console match exactly |
| "Invalid client" error | Check client ID and secret are correct |
| Social login button not showing | Verify Social Login Key is enabled and saved |
| CORS errors | Add your domain to Authorized JavaScript Origins |

---

## Verification Checklist

- [ ] Google Cloud Console redirect URIs updated
- [ ] Google Cloud Console JavaScript origins updated
- [ ] `site_config.json` contains correct client ID and secret
- [ ] Social Login Key created in Frappe with correct details
- [ ] Social Login Key is enabled (checkbox checked)
- [ ] System Settings has "Enable Social Login" checked
- [ ] Site restarted after configuration changes
- [ ] Test login successful

---

## Security Notes

⚠️ **Important Security Considerations:**

1. **Never commit credentials to version control**
   - Add `site_config.json` to `.gitignore`
   - Use environment variables for production

2. **Rotate secrets regularly**
   - Change client secret periodically
   - Update in both Google Console and Frappe

3. **Use HTTPS in production**
   - Never use HTTP for OAuth in production
   - Ensure SSL certificate is valid

4. **Restrict OAuth scopes**
   - Only request necessary Google permissions
   - Review OAuth consent screen settings

---

## Environment-Specific Configuration

### Local Development (casahub.local)

```bash
# Site config
bench --site casahub.local set-config google_client_id "553782146847-4behr365rs36qhc5rd7p9vs1n854dagq.apps.googleusercontent.com"
bench --site casahub.local set-config google_client_secret "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"

# Redirect URI
http://casahub.local/api/method/frappe.integrations.oauth2_logins.custom/google

# JavaScript Origin
http://casahub.local
```

### Production (Frappe Cloud)

```bash
# Site config
bench --site casahub.jh.frappe.cloud set-config google_client_id "553782146847-4behr365rs36qhc5rd7p9vs1n854dagq.apps.googleusercontent.com"
bench --site casahub.jh.frappe.cloud set-config google_client_secret "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"

# Redirect URI
https://casahub.jh.frappe.cloud/api/method/frappe.integrations.oauth2_logins.custom/google

# JavaScript Origin
https://casahub.jh.frappe.cloud
```

---

## Troubleshooting

### Debug Commands

**Check site configuration:**
```bash
cat sites/casahub.local/site_config.json | grep google
```

**Verify Social Login Keys:**
```bash
bench --site casahub.local console
```

In the console:
```python
import frappe
frappe.get_all('Social Login Key', 
    filters={'enable_social_login': 1}, 
    fields=['name', 'social_login_provider', 'client_id'])
```

**Check error logs:**
```bash
tail -f sites/casahub.local/logs/web.error.log
```

### Common Error Messages

**"Error 400: redirect_uri_mismatch"**
- **Cause:** Redirect URI in Google Console doesn't match the one Frappe is using
- **Fix:** Copy the exact redirect URI from the error message and add it to Google Console

**"Error 401: invalid_client"**
- **Cause:** Client ID or Client Secret is incorrect
- **Fix:** Double-check credentials in `site_config.json` and Social Login Key

**"Social login is disabled"**
- **Cause:** Social Login Key is not enabled or System Settings doesn't have social login enabled
- **Fix:** Enable in both Social Login Key document and System Settings

---

## Additional Resources

- **Google Cloud Console:** [https://console.cloud.google.com/auth/clients?project=casahub-476121](https://console.cloud.google.com/auth/clients?project=casahub-476121)
- **Frappe Documentation:** [https://frappeframework.com/docs/user/en/guides/integration/oauth](https://frappeframework.com/docs/user/en/guides/integration/oauth)
- **OAuth 2.0 Playground:** [https://developers.google.com/oauthplayground/](https://developers.google.com/oauthplayground/)

---

## Support

For issues or questions:
1. Check Frappe error logs: `sites/casahub.local/logs/`
2. Review Google Cloud Console audit logs
3. Verify all configuration steps completed
4. Test with a different Google account

---

**Last Updated:** 2025-11-29  
**Version:** 1.0  
**Maintainer:** CasaHub Development Team
```

